<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		组合继承<br>
		一定要明白：那些属性是私有的，哪些是公有的
		
	</body>
	<script type="text/javascript">
		function Humans(name){
			this.name=name;
			this.clothing=["trousers","dress","jacket"];
		}
		Humans.prototype.sayName=function(){
			alert(this.name);
		};
		function Man(name,age){
			Humans.call(this,name);    //继承属性
			this.age=age;
		}
		Man.prototype=new Humans();    //继承方法
		Man.prototype.sayAge=function(){
			alert(this.age);
		};
	
		var man1=new Man("mary",38);
		man1.clothing.push("coat");
		alert(man1.clothing);     //输出"trousers,dress,jacket,coat"
		man1.sayName();            //输出mary
		man1.sayAge();            //输出38
		var man2=new Man("tom",26);
		alert(man2.clothing);    //输出"trousers,dress,jacket"
		man2.sayName();            //输出tom
		man2.sayAge();            //输出26
		
	</script>
</html>
